<?php
	session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<title>
HSE
</title>

<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<style type="text/css">
A{font-weight: bold; color:#000; text-align:bottom; font-family:'Times New Roman'; font-size:10pt; text-decoration:none; }
div.parent{visible:none;}
</style>
</head>

<body>

<div id="container">

	<!-- Start of Page Header -->

	<div id="page_header">

		<div id="page_heading">
		<h1><span></span></h1>
		<h2><span></span></h2>
		</div>

		<div id="page_headerlinks">
			<ul>
                <li> 
					<?php 
						if (isset($_SESSION['user_name'])) 
							echo $_SESSION['user_name']."</li><li class=\"last\"><a href=\"logout.php\">Log-out"; 
						else 
							echo "Guest</li><li class=\"last\"><a href=\"login.htm\">Log-in"; 
					?></a></li>
			</ul>
		</div>
        <div id="change-pass">
			<ul>
            	<?php
					if (isset($_SESSION['user_name'])) 
						echo "<li class=\"belk\"><a href=\"change-password.php\">change password</a></li>";
				?>
            </ul>
		</div>

		<div class="clearthis">&nbsp;</div>

	</div>

	<!-- End of Page Header -->
<!-- Start of Left Sidebar -->

	<div id="left_sidebar">




		<!-- Start of Categories Box -->

		<div id="categories">
			<div id="categories_header">
			<h2>Categories</h2>
			</div>
        </div>
		<!-- start of categories tree -->

        <Script Language="JavaScript">
        <!--

        ///////////////////////////////////////////////////////////
        //www.fortochka.com
        //Alexander Babichev Copyright
        //this script is free for private use "as is"
        //under the condition:
        //the copyright notice should be left unchanged.
        ////////////////////////////////////////////////////////////
        var currentA = 'm0'

        function list(name,url){
            this.name = name
            this.url = url
           }

        var dir = new Array()

        //=============================================================

        var root = 'Health, Safety and Environment'

        var dir0 = new Array()
        var dir1 = new Array()
        var dir2 = new Array()

        dir[0] = "Environmental"
        dir0[0] = new list("Energy Conservation","kategori.php?id=1")
        dir0[1] = new list("Noise Management","kategori.php?id=2")
        dir0[2] = new list("Water Conservation","kategori.php?id=3")
        dir0[3] = new list("Contaminated Land","kategori.php?id=4")
        
        dir[1] = 'Community Health and Safety'
        dir1[0] = new list("Water Quality and Availability","kategori.php?id=5")
        dir1[1] = new list("Structural safety","kategori.php?id=6")
        dir1[2] = new list("Life and Fire Safety","kategori.php?id=7")
		dir1[2] = new list("Traffic Safety","kategori.php?id=8")
		dir1[2] = new list("Disease Prevention","kategori.php?id=9")
		dir1[2] = new list("Emergency Preparedness","kategori.php?id=10")
        
        dir[2] = 'Occupational Health and Safety'
        dir2[0] = new list("General Facility Operation","kategori.php?id=11")
        dir2[1] = new list("Communication and Training","kategori.php?id=12")
        dir2[2] = new list("Personal Protective Equipment","kategori.php?id=13")
        dir2[3] = new list("Monitoring","kategori.php?id=14")

        //=============================================================

        var folderImgArray = new Array()
        var treeImgArray = new Array()

        function precasheLeftSide(){
        for (var i = 0; i<=4; i++){
           folderImgArray[i] = new Image()
           treeImgArray[i] = new Image()
        }

        folderImgArray[0].src = "LeftSide/folder.gif"
        folderImgArray[1].src = "LeftSide/openfolder.gif"
        treeImgArray[0].src = "LeftSide/Tplus.gif"
        treeImgArray[1].src = "LeftSide/Tminus.gif"
        treeImgArray[2].src = "LeftSide/Lplus.gif"
        treeImgArray[3].src = "LeftSide/Lminus.gif"
        }

        function writeSecondLevel(myArray,ii){
            for (kk=0;kk<myArray.length;kk++){
                if (kk==myArray.length-1){
                document.write("<nobr><img src='LeftSide/I.gif' align='absmiddle'><img src='LeftSide/L.gif' align='absmiddle'><a style='color:#222;' name='m" + ii + "n" + kk + "' id='m" + ii + "n" + kk + "' href='" + myArray[kk].url + "' Target='right' OnClick='this.blur(); changeColor(this.name); return true;'><img src='LeftSide/doclogo.png' align='absmiddle' border='0'>&nbsp;" + myArray[kk].name + "</nobr></a><br>")
                }
                else{
                document.write("<nobr><img src='LeftSide/I.gif' align='absmiddle'><img src='LeftSide/T.gif' align='absmiddle'><a style='color:#222;' name='m" + ii + "n" + kk + "' id='m" + ii + "n" + kk + "' href='" + myArray[kk].url + "' Target='right' OnClick='this.blur(); changeColor(this.name); return true;'><img src='LeftSide/doclogo.png' align='absmiddle' border='0'>&nbsp;" + myArray[kk].name + "</nobr></a><br>")
                }
            }
        }

        function writeLastSecondLevel(myArray,ii){
            for (kk=0;kk<myArray.length;kk++){
                if (kk==myArray.length-1){
                document.write("<nobr><img src='LeftSide/blank.gif' align='absmiddle'><img src='LeftSide/L.gif' align='absmiddle'><a style='color:#222;' name='m" + ii + "n" + kk + "' id='m" + ii + "n" + kk + "' href='" + myArray[kk].url + "' Target='right' OnClick='this.blur(); changeColor(this.name); return true;'><img src='LeftSide/doclogo.png' align='absmiddle' border='0'>&nbsp;" + myArray[kk].name + "</nobr></a><br>")
                }
                else{
                document.write("<nobr><img src='LeftSide/blank.gif' align='absmiddle'><img src='LeftSide/T.gif' align='absmiddle'><a style='color:#222;' name='m" + ii + "n" + kk + "' id='m" + ii + "n" + kk + "' href='" + myArray[kk].url + "' Target='right' OnClick='this.blur(); changeColor(this.name); return true;'><img src='LeftSide/doclogo.png' align='absmiddle' border='0'>&nbsp;" + myArray[kk].name + "</nobr></a><br>")
                }
            }
        }

        function changeFolder($1){
            if (document.all){
                currentFolder = eval("document.all." + $1 + "Folder")
                currentTree = eval("document.all." + $1 + "Tree")
                currentDiv = eval("document.all." + $1 + "Div")
            }
            if (!document.all && document.getElementById){
                currentFolder = eval("document.getElementById('" + $1 + "Folder" + "')")
                currentTree = eval("document.getElementById('" + $1 + "Tree" + "')")
                currentDiv = eval("document.getElementById('" + $1 + "Div" + "')")
            }

           var cfArr = currentFolder.src.split("/")
           var fiArr0 = folderImgArray[0].src.split("/")
           var fiArr1 = folderImgArray[1].src.split("/")

           var ctArr = currentTree.src.split("/")
           var tiArr0 = treeImgArray[0].src.split("/")
           var tiArr1 = treeImgArray[1].src.split("/")
           var tiArr2 = treeImgArray[2].src.split("/")
           var tiArr3 = treeImgArray[3].src.split("/")

            if (cfArr[(cfArr.length-1)]==fiArr0[(fiArr0.length-1)]){
                currentFolder.src = folderImgArray[1].src;
                if (ctArr[(ctArr.length-1)]==tiArr0[(tiArr0.length-1)]){
                    currentTree.src = treeImgArray[1].src;
                }
                if (ctArr[(ctArr.length-1)]==tiArr2[(tiArr2.length-1)]){
                    currentTree.src = treeImgArray[3].src;
                }
                currentDiv.style.display=''
            }

            if (cfArr[(cfArr.length-1)]==fiArr1[(fiArr1.length-1)]){
                currentFolder.src = folderImgArray[0].src;
                if (ctArr[(ctArr.length-1)]==tiArr1[(tiArr1.length-1)]){
                    currentTree.src = treeImgArray[0].src;
                }
                if (ctArr[(ctArr.length-1)]==tiArr3[(tiArr3.length-1)]){
                    currentTree.src = treeImgArray[2].src;
                }
                currentDiv.style.display='none'
            }
        }

        function changeColor(aName){
        if (aName != currentA){
            if (aName == 'm0'){
                document.getElementById(aName).style.color='black'
            }
            else{
                document.getElementById(aName).style.color='green'

            }
        if (currentA != 'm0'){
            document.getElementById(currentA).style.color='#9F8BFC'
        }
                currentA = aName
                //alert(currentA)
        }
        }

        function writeTree(){
var ii
document.write("<BR><a href='right.htm' style=color:black;font-size:16px; Target='right' name = 'm0' ID='m0' OnClick='this.blur(); changeColor(this.name);'><img src='LeftSide/Logo.gif' align='absmiddle' border='0'>&nbsp;" + root + "</nobr></a><br>")

	for (ii=0;ii<dir.length;ii++){
		if (ii==dir.length-1){
		document.write("<div><a style=font-size:14px;color:#000; href='#' onClick='this.blur(); ")
		document.write('changeFolder("m' + ii + '"); return false')
		document.write("'><nobr><img name='m" + ii + "Tree' id='m" + ii + "Tree' src='LeftSide/Lplus.gif' align='top' border='0'><img name='m" + ii + "Folder' id='m" + ii + "Folder' src='LeftSide/folder.gif' align='top' border='0'>&nbsp;<b>" + dir[ii] + "</b></nobr></a></div>")
		document.write("<div Name='m" + ii + "Div' ID='m" + ii + "Div' style=display:none;>")
		writeLastSecondLevel(eval("dir"+ii),ii)
		}
	else{
		document.write("<div><a style=font-size:14px;color:#000; href='#' onClick='this.blur(); ")
		document.write('changeFolder("m' + ii + '"); return false')
		document.write("'><nobr><img name='m" + ii + "Tree'  id='m" + ii + "Tree' src='LeftSide/Tplus.gif' align='top' border='0'><img name='m" + ii + "Folder' id='m" + ii + "Folder' src='LeftSide/folder.gif' align='top' border='0'>&nbsp;" + dir[ii] + "</nobr></a></div>")
		document.write("<div Name='m" + ii + "Div' ID='m" + ii + "Div' style=display:none;>")
		writeSecondLevel(eval("dir"+ii),ii)
		}
	document.write("</div>")
	}

}

        precasheLeftSide()
        writeTree()
        // -->
        </Script>


		<!-- End of Categories Box -->


	</div>

	<!-- End of Left Sidebar -->

	<!-- Start of Page Menu -->

  <div id="page_menu">
		<ul>
            <li><a href="index.php">Home</a></li> 
            <li>
                <a href="sop.htm">SOP</a>
            </li>
            <li>
                <a href="accident.htm">Accident</a>
            </li>
		</ul>
	</div>

	<!-- End of Page Menu -->

	<!-- Start of Main Content Area -->

<div id="main_content">

		<!-- Start of New Item Description -->

		<div id="new_item">

			<div id="register_header">
			<h1 style="color:#B5B18C">Register Operator</h1>
			</div>

			<!-- <div id="new_item_image">
			<img src="images/item_new.gif" width="242" height="180" alt="New Item Name" />
			</div> -->

			<div id="new_item_text">
			
					<form name="register_form" action="register.php" class="form_settings" method="post" enctype="multipart/form-data">
						<br /><br />
						<table>
							<tr>
								<td style="font-size:16px;color:#293336">User Name<label id="fill"> &nbsp;*</label></td><td style="font-size:16px;width:30px;text-align:center;color:#293336" > : </td><td style="font-size:16px"><input type="text" name="userName" style="color:#293336;font-size:16px"/></td>
							</tr>
							<tr>
							<td colspan="3">&nbsp;</td>
							</tr>
							<tr>
								<td style="font-size:16px;color:#293336">Password<label id="fill"> &nbsp;*</label></td><td style="font-size:16px;width:30px;text-align:center;color:#293336" > : </td><td style="font-size:16px"><input type="password" name="password" style="color:#293336;font-size:16px"/></td>
							</tr>
							<tr>
							<td colspan="3">&nbsp;</td>
							</tr>
							<tr>
								<td style="font-size:16px;color:#293336">Confirm Password<label id="fill"> &nbsp;*</label></td><td style="font-size:16px;width:30px;text-align:center;color:#293336" > : </td><td style="font-size:16px"><input type="password" name="confirmPassword" style="color:#293336;font-size:16px"/></td>
							</tr>
							<tr>
							<td colspan="3">&nbsp;</td>
							</tr>
							<tr>
							<td height="56" colspan="2" align="left"><input type="submit" value="Submit" />
							</td>
							<td>
									<label id="fill">*</label><label> &nbsp; = required field</label>
							</td>
							</tr>
							<td colspan="3">&nbsp;</td>
							</tr>
							<tr>
							<td colspan="3">&nbsp;</td>
							</tr>
					</form> 
						</table>
		
                            <?php
                                $con = mysql_connect("localhost","root","");
                                if (!$con)
                                {
                                    die('Could not connect: ' . mysql_error());
                                }

                                mysql_select_db("hse", $con);
								
								if (isset($_POST['userName'])) {
									// get selected category
									if($_POST['userName']!= "" && $_POST['password']!= "" && $_POST['confirmPassword']!= ""){
										$varUserName = $_POST['userName'];
										$varPassword = $_POST['password'];
										$varConfirmPassword = $_POST['confirmPassword'];
										$boolValidRegister = TRUE;

										//check availability user_name
										$sqlCurrentUserName = "Select user_name from user";
										$execUserName = mysql_query($sqlCurrentUserName);
										while ($resultsUserName = mysql_fetch_array($execUserName) ){
											if ($resultsUserName['user_name'] == $varUserName){
												echo "<p>User Name not Available, please try with different name!</p>";
												// user name not available
												$boolValidRegister = FALSE;
												break;
											}
										}

										// check password confirmation, if Password confirmation is different from password, registration failed
										if ($varPassword != $varConfirmPassword){
											$boolValidRegister = False;
											echo "<p>Password Confirmation wrong!</p>";
										}

										// if user name available
										if ($boolValidRegister == True) {
											$sqlInsertUser = "Insert into user Values ('$varUserName', '$varPassword', 'operator')";
											// execute query
											mysql_query($sqlInsertUser, $con);
											echo "<p>Register Successfully</p>";
										}
									}
									else{
									   echo '<p style="font-size:14px;">Please fill all required field..</p>';
									}
								}
                            ?>
                            </br>
                            <a href="index.php"><p style="color:#827C3D;font-size: 14px;"><-- back to home</p></a>
			</div>
		</div>

		<!-- End of New Item Description -->

  </div>

	<!-- End of Main Content Area -->


	<div class="clearthis">&nbsp;</div>


	<!-- Start of Page Footer -->

	<div id="page_footer">


		<div id="powered_by">
		UPT KEAMANAN, KESEHATAN, KESELAMATAN KERJA DAN LINGKUNGAN
		</div>

		<div class="clearthis">&nbsp;</div>
	</div>

	<!-- End of Page Footer -->

</div>

</body>
</html>